<?php 
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../DAO/PageDAO.php';
class PageService
{
	public function create(BaseContext $context, ServiceResult $result, PageDomain $pageDomain)
	{
		try
		{
			$pageDAO = new PageDAO($context);
			$pageDAO->create($pageDomain);
			$result->setSuccess();
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

	public function update(BaseContext $context, ServiceResult $result, PageDomain $pageDomain)
	{
		try
		{
			$pageDAO = new PageDAO($context);
			$pageDAO->update($pageDomain);
			$result->setSuccess();
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

	public function delete(BaseContext $context, ServiceResult $result, $oid)
	{
		try
		{
			$pageDAO = new PageDAO($context);
			$pageDAO->delete($oid);
			$result->setSuccess();
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

	public function findByOid(BaseContext $context, ServiceResult $result, $oid)
	{
		try
		{
			$pageDAO = new PageDAO($context);
			$pageDomain = $pageDAO->findByOid($oid);
			$result->setSuccess();
			return $pageDomain;
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

	public function findAll(BaseContext $context, ServiceResult $result)
	{
		try
		{
			$pageDAO = new PageDAO($context);
			$pageDomainArr = $pageDAO->findAll();
			$result->setSuccess();
			return $pageDomainArr;
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

}
?>